import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Strawberry implements Runnable {
	static interface Operation {
		long neutral();
		long op(long a, long b);
	}

	static class RhombSums {
		private final int height;
		private final int width;
		final long[][] field;
		final Operation op;
		private final int querySize;
		final long[][] sums;
		private final boolean borderOnly;

		RhombSums(int height, int width, long[][] field, Operation op, int querySize, boolean borderOnly) {
			this.height = height;
			this.width = width;
			this.field = field;
			this.op = op;
			this.querySize = querySize;
			this.sums = new long[height][width];
			for (int i = 0; i < height; ++i) Arrays.fill(sums[i], op.neutral());
			this.borderOnly = borderOnly;
			initialize();
		}

		private void initialize() {
			int maxp2 = 0;
			int maxp2v = 1;
			while (maxp2v <= querySize) {
				++maxp2;
				maxp2v *= 2;
			}
			long[][] p2sum = new long[height][width];
			long[][] p2QuerySize = new long[height][width];
			long[][] p2QuerySizeLess1 = new long[height][width];
			for (int row = 0; row < height; ++row)
				for (int col = 0; col < width; ++col) {
					p2sum[row][col] = field[row][col];
					p2QuerySize[row][col] = op.neutral();
					p2QuerySizeLess1[row][col] = op.neutral();
				}
			int p2v = 1;
			for (int p2 = 0; p2 < maxp2; ++p2) {
				if ((querySize & p2v) != 0) {
					int offset = querySize & (p2v - 1);
					for (int row = 0; row < height; ++row)
						for (int col = 0; col < width; ++col) {
							p2QuerySize[row][col] = op.op(p2QuerySize[row][col], p2sum[(row + offset) % height][((col - offset) % width + width) % width]);
						}
				}
				if (((querySize - 1) & p2v) != 0) {
					int offset = (querySize - 1) & (p2v - 1);
					for (int row = 0; row < height; ++row)
						for (int col = 0; col < width; ++col) {
							p2QuerySizeLess1[row][col] = op.op(p2QuerySizeLess1[row][col], p2sum[(row + offset) % height][((col - offset) % width + width) % width]);
						}
				}
				long[][] np2sum = new long[height][width];
				for (int row = 0; row < height; ++row)
					for (int col = 0; col < width; ++col) {
						np2sum[row][col] = op.op(p2sum[row][col], p2sum[(row + p2v) % height][((col - p2v) % width + width) % width]);
					}
				p2v *= 2;
				p2sum = np2sum;
			}
			if (borderOnly) {
				for (int row = 0; row < height; ++row)
					for (int col = 0; col < width; ++col) {
						sums[row][col] = op.op(sums[row][col], p2QuerySize[row][col]);
						int offset = querySize - 1;
						sums[row][col] = op.op(sums[row][col], p2QuerySize[(row + offset) % height][((col + offset) % width + width) % width]);
					}
				for (int row = 0; row < height; ++row)
					for (int col = 0; col < width; ++col) {
						p2sum[row][col] = field[row][col];
						p2QuerySize[row][col] = op.neutral();
						p2QuerySizeLess1[row][col] = op.neutral();
					}
				p2v = 1;
				for (int p2 = 0; p2 < maxp2; ++p2) {
					if ((querySize & p2v) != 0) {
						int offset = querySize & (p2v - 1);
						for (int row = 0; row < height; ++row)
							for (int col = 0; col < width; ++col) {
								p2QuerySize[row][col] = op.op(p2QuerySize[row][col], p2sum[(row + offset) % height][((col + offset) % width + width) % width]);
							}
					}
					long[][] np2sum = new long[height][width];
					for (int row = 0; row < height; ++row)
						for (int col = 0; col < width; ++col) {
							np2sum[row][col] = op.op(p2sum[row][col], p2sum[(row + p2v) % height][((col + p2v) % width + width) % width]);
						}
					p2v *= 2;
					p2sum = np2sum;
				}
				for (int row = 0; row < height; ++row)
					for (int col = 0; col < width; ++col) {
						sums[row][col] = op.op(sums[row][col], p2QuerySize[row][col]);
						int offset = querySize - 1;
						sums[row][col] = op.op(sums[row][col], p2QuerySize[(row + offset) % height][((col - offset) % width + width) % width]);
					}
			} else {
				for (int row = 0; row < height; ++row)
					for (int col = 0; col < width; ++col) {
						p2sum[row][col] = p2QuerySize[row][col];
					}
				p2v = 1;
				for (int p2 = 0; p2 < maxp2; ++p2) {
					if ((querySize & p2v) != 0) {
						int offset = querySize & (p2v - 1);
						for (int row = 0; row < height; ++row)
							for (int col = 0; col < width; ++col) {
								sums[row][col] = op.op(sums[row][col], p2sum[(row + offset) % height][((col + offset) % width + width) % width]);
							}
					}
					long[][] np2sum = new long[height][width];
					for (int row = 0; row < height; ++row)
						for (int col = 0; col < width; ++col) {
							np2sum[row][col] = op.op(p2sum[row][col], p2sum[(row + p2v) % height][((col + p2v) % width + width) % width]);
						}
					p2v *= 2;
					p2sum = np2sum;
				}
				for (int row = 0; row < height; ++row)
					for (int col = 0; col < width; ++col) {
						p2sum[row][col] = p2QuerySizeLess1[row][col];
					}
				p2v = 1;
				for (int p2 = 0; p2 < maxp2; ++p2) {
					if (((querySize - 1) & p2v) != 0) {
						int offset = (querySize - 1) & (p2v - 1);
						for (int row = 0; row < height; ++row)
							for (int col = 0; col < width; ++col) {
								sums[(row - 1 + height) % height][col] = op.op(sums[(row - 1 + height) % height][col], p2sum[(row + offset) % height][((col + offset) % width + width) % width]);
							}
					}
					long[][] np2sum = new long[height][width];
					for (int row = 0; row < height; ++row)
						for (int col = 0; col < width; ++col) {
							np2sum[row][col] = op.op(p2sum[row][col], p2sum[(row + p2v) % height][((col + p2v) % width + width) % width]);
						}
					p2v *= 2;
					p2sum = np2sum;
				}
			}
		}

		void dump(PrintWriter writer, String title) {
			writer.println(title);
			for (int i = 0; i < height; ++i) {
				for (int j = 0; j < width; ++j)
					writer.print(sums[i][j] + " ");
				writer.println();
			}
			writer.println();
		}
	}

    private void solve() {
		int height = nextInt();
		int width = nextInt();
		long[][] field = new long[height][width];
		for (int row = 0; row < height; ++row)
			for (int col = 0; col < width; ++col) {
				field[row][col] = nextLong();
			}
		int bigRhombSize = nextInt();
		int smallRhombSize = nextInt();
		RhombSums bigSums = new RhombSums(height, width, field, new Operation() {
			public long neutral() {
				return 0;
			}

			public long op(long a, long b) {
				return a + b;
			}
		}, bigRhombSize + 1, false);
		RhombSums smallSums = new RhombSums(height, width, field, new Operation() {
			public long neutral() {
				return 0;
			}

			public long op(long a, long b) {
				return a + b;
			}
		}, smallRhombSize + 1, false);
		RhombSums smallMaxes = new RhombSums(height, width, smallSums.sums, new Operation() {
			public long neutral() {
				return Long.MAX_VALUE;
			}

			public long op(long a, long b) {
				return Math.min(a, b);
			}
		}, bigRhombSize - smallRhombSize + 1, true);
		//bigSums.dump(writer, "Big sums:");
		//smallSums.dump(writer, "Small sums:");
		//smallMaxes.dump(writer, "Small maxes:");
		long res = 0;
		for (int row = 0; row < height; ++row)
			for (int col = 0; col < width; ++col) {
				long cur = bigSums.sums[row][col] - smallMaxes.sums[row][col];
				res = Math.max(res, cur);
			}
		writer.println(res);
    }

    public static void main(String[] args) {
        new Strawberry().run();
    }

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    static final String TASK_ID = "strawberry";

    public void run() {
        try {
            reader = new BufferedReader(new FileReader(TASK_ID + ".in"));
            tokenizer = null;
            writer = new PrintWriter(TASK_ID + ".out");
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    int nextInt() {
        return Integer.parseInt(nextToken());
    }

    long nextLong() {
        return Long.parseLong(nextToken());
    }

    double nextDouble() {
        return Double.parseDouble(nextToken());
    }

    String nextToken() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }
}
